<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>LAPACK build and test guide</title>
<link rel="stylesheet" type="text/css" href="https://gcc.gnu.org/gcc.css" />
</head>

<body>
<h1>LAPACK build and test guide</h1>

<p>This page is a guide to building the
<a href="http://www.netlib.org/lapack/index.html">LAPACK</a> linear
algebra package and running its testing and timing programs as part of
GCC integration testing.</p>

<h2>Resource usage</h2>

<p>The LAPACK distribution, available from the netlib repository at
<a href="http://www.netlib.org/lapack/lapack.tgz">lapack.tgz</a>,
is a 5 MB file.  The uncompressed LAPACK distribution comprises some 35 MB
of source files.  Building the libraries, test and timing programs adds
between 80 and 100 MB of objects, libraries and executables to this.</p>

<p>On a 750 Mhz Pentium III laptop, building and testing LAPACK takes
about 30 minutes.  Building and running the timing programs takes
a lot longer.</p>

<h2>Prepare</h2>

<p>To prepare the LAPACK distribution, do the following:</p>
<ul>
<li>Unpack the .tgz file:
    <ul>
    <li><code>tar zxf lapack.tgz</code>, or</li>
    <li><code>gunzip -c lapack.tgz | tar xf -</code></li>
    </ul>
</li>
<li>Change directory to the repository thus created:
    <ul>
    <li><code>cd LAPACK</code></li>
    </ul>
</li>
<li>Edit the include file of the main Makefile (<code>make.inc</code>):
    <ul>
    <li><code>PLAT = G77</code></li>
    <li><code>FORTRAN = &lt;path_to_GCC_installation&gt;/bin/g77</code></li>
    <li><code>OPTS = -g -O2 -funroll-loops</code></li>
    <li><code>NOOPT = -g</code></li>
    <li><code>LOADER = $(FORTRAN)</code></li>
    <li><code>LOADOPTS = -Wl,-rpath=&lt;path_to_GCC_installation&gt;/lib
        </code></li>
    <li><code>RANLIB = ranlib</code></li>
    <li><code>BLASLIB = ../../blas$(PLAT).a</code></li>
    </ul>
    Note that the value of RANLIB depends on ranlib being
    available (and necessary) on your operating system.
</li>
<li>If you want to test LAPACK with an uninstalled compiler,
    change the following in the above:
    <ul>
    <li>Add: <code>GCC_DIR = /path/to/gcc/build/directory</code></li>
    <li>Change: <code>FORTRAN = $(GCC_DIR)/gcc/g77 -B$(GCC_DIR)/gcc/</code></li>
    <li>Change: <code>LOADER = $(FORTRAN) -L$(GCC_DIR)/&lt;target&gt;/libf2c</code></li>
    </ul>
    where <code>&lt;target&gt;</code> is the target triple for your system (e.g.
    <code>mips-sgi-irix6.5</code>)
</li>
</ul>

<p>A final note:  On 64-bit targets, LAPACK cannot be built using GCC 2.95.2
without specifying the <code>-femulate-complex</code> flag.  Building it
using GCC 3.x should not need that flag.</p>

<p>On Alphas it is necessary to add the flag <code>-mieee</code> to OPTS,
NOOPT and LOADOPTS.</p>

<h2>Build</h2>

<p>The LAPACK Makefile assumes that you have the current
directory in your path.  If this is not the case in your
shell setup, use the following command line:</p>

<code>(PATH=$PATH:. export PATH;
make install blaslib lapacklib tmglib testing blas_testing)</code>

<p>If the main memory in your machine is 512 Mbyte or larger,
you are able to run the timing programs in addition to the
testing programs that are run with the command above.  In that
case, issue the command:</p>

<code>(PATH=$PATH:. export PATH;
make install blaslib lapacklib tmglib
testing blas_testing timing blas_timing)</code>

<h2>Test</h2>

<p>The output of the testing programs is written into files with
extension <code>.out</code> in the <code>TESTING</code> subdirectory of
the main LAPACK directory.  Use the command <code>grep -i fail *.out</code>
to find the number of failing tests.</p>

<p>GCC 3.1 should not result in more failures than GCC 3.0.4</p>

<h2>Interoperability testing</h2>

<p>The make targets <code>testing</code> and <code>blas_testing</code>
build tests that use libraries built for the previous targets.  LAPACK
can be used to test interoperability of two compilers by first editing
the <code>make.inc</code> file to use one compiler and building all of
the libraries with that, and then modifying <code>make.inc</code> to
specify a second compiler and making the testing targets.</p>

<h2>Time</h2>

<p>TBD</p>

<h2>Cleanup</h2>

<p>Cleanup (to prepare the directory for a fresh run, e.g.
with another version of the compiler), has to be done as follows:</p>

<code>(PATH=$PATH:. export PATH; make clean;
rm `find . -name '*.SUMM' -print`)</code>

<p>The reason for this is that the LAPACK programs leave files
behind with the extension .SUMM, which are opened with <code>
STATUS='NEW'</code> - this will result in an abort if the files
already exist.</p>

</body>
</html>
